﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<CRM.Database.Model.Equipments>>" %>

<%@ Import Namespace="CRM.Database.Model" %>
<%@ Import Namespace="CRM.Resourses" %>




<% Html.DevExpress().GridView(settings =>
                                      {
                                          settings.Name = "gdEquipmentList";
                                          settings.KeyFieldName = "IdEquipment";
                                          settings.Settings.ShowFilterRow = true;

                                          settings.CallbackRouteValues =
                                          new { Action = "GetEquipEditCallBack" };
                                          settings.ClientSideEvents.RowClick = "OnRowClick";
                                      //  settings.ClientSideEvents.SelectionChanged = string.Format("function(s, e) {{ ddeEquipment.SetKeyValue({0}.GetRowKey(e.visibleIndex));  ddeEquipment.SetText({0}.GetRowKey(e.visibleIndex)); }}", settings.Name);
                                        settings.SettingsBehavior.AllowSelectByRowClick = true;
                                          settings.SettingsBehavior.AllowSelectSingleRowOnly = true;

                                          //settings.Columns.Add(column =>
                                          //                         {
                                          //                             var col = new EquipmentTypesCollection();
                                          //    column.FieldName = "IdEquipmentType";
                                          //    column.Caption = Resourses.EquipmentType;
                                          //    column.ColumnType = MVCxGridViewColumnType.ComboBox;
                                          //    var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                          //    if (comboBoxProperties != null)
                                          //    {

                                          //        comboBoxProperties.DataSource =col.EquipmentTypesList;
                                          //        //collection.EquipmentTypes;
                                          //        comboBoxProperties.TextField = "LocalizedName";
                                          //        comboBoxProperties.ValueField = "IdEquipmentType";
                                          //        comboBoxProperties.ValueType = typeof(int);
                                          //    }
                                          //});

                                          //settings.Columns.Add(column =>
                                          //                         {
                                          //                             var col = new VendorsCollection();
                                          //    column.FieldName = "IdVendor";
                                          //    column.Caption = Resourses.ToolVendor;
                                          //    column.ColumnType = MVCxGridViewColumnType.ComboBox;
                                          //    var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                          //    if (comboBoxProperties != null)
                                          //    {

                                          //        comboBoxProperties.DataSource =
                                          //            col.VendorsList;

                                          //        comboBoxProperties.TextField = "VendorName";
                                          //        comboBoxProperties.ValueField = "IdVendor";
                                          //        comboBoxProperties.ValueType = typeof(int);
                                          //    }
                                          //});

                                          settings.Columns.Add(column =>
                                          {
                                              column.FieldName = "EquipmentTypeNameLocalized";
                                              column.Caption = Resourses.EquipmentType;
                                              column.Settings.AutoFilterCondition =
                                                  AutoFilterCondition.Contains;
                                          });

                                          settings.Columns.Add(column =>
                                          {
                                              column.FieldName = "VendorNameExt";
                                              column.Caption = Resourses.VendorName;
                                              column.Settings.AutoFilterCondition =
                                                  AutoFilterCondition.Contains;
                                          });

                                          settings.Columns.Add(column =>
                                          {
                                              column.FieldName = "Model";
                                              column.Caption = Resourses.EquipmentModel;
                                              column.Settings.AutoFilterCondition =
                                                  AutoFilterCondition.Contains;
                                          });

                                       
                                      }).Bind(Model).GetHtml();
       
       
       
   %> 

   

